package com.bocai.dahuatech.ui.frag;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;

import com.bocai.dahuatech.R;
import com.bocai.dahuatech.base.BaseFragment;
import com.bocai.dahuatech.ui.activity.ProductSizepicDetailActivity;
import com.bocai.dahuatech.ui.adapter.ProductSizePicAdapter;
import com.bocai.dahuatech.ui.view.MyListView;

import butterknife.Bind;
import butterknife.ButterKnife;


/**
 * 产品尺寸图
 */
@SuppressLint("ValidFragment")
public class ProductSizePicFragment extends BaseFragment {
    private View view;
    @Bind(R.id.lv_productsizepic)
    MyListView lvpic;
    String info;
    String pic[];
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.productsizepic, container, false);
        initView(view);
        return view;
    }
    public ProductSizePicFragment(String info){
        this.info=info;

    }
    private void initView(View view) {
        ButterKnife.bind(this, view);
        lvpic.setFocusable(false);
        if(!info.equals("")){
            pic=info.split(",");
            lvpic.setAdapter(new ProductSizePicAdapter(getActivity(),pic));
        }
        initEvent();
    }

    private void initEvent() {
        lvpic.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Intent intent=new Intent(getActivity(), ProductSizepicDetailActivity.class);
                intent.putExtra("picurl",pic[position]);
                startActivity(intent);
            }
        });
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.unbind(this);
    }
    @Override
    public void onResume() {
        super.onResume();
    }


}
